import numpy as np
from scipy.spatial.transform import Rotation
import tf.transformations as tf

def deg2rad(deg):
    return deg * np.pi / 180. 

def rad2deg(rad):
    return rad / np.pi * 180. 

roll = 30
pitch = 45
yaw = 60

# 下面2个等价
R = Rotation.from_euler('xyz', [roll, pitch, yaw], degrees=True)
q = Rotation.as_quat(R)
R = Rotation.as_matrix(R)
print(q)
print(R)

R = tf.euler_matrix(deg2rad(yaw), deg2rad(pitch), deg2rad(roll), axes='rzyx')
q = tf.quaternion_from_matrix(R)
print(q)
print(R)